home *** CD-ROM | disk | FTP | other *** search
- class Class.Control_cpu extends Class.Control
- {
- var hitRate;
- var role;
- var opp;
- var side;
- var bullet;
- var meter_mc;
- var angle;
- var distance;
- var startX;
- var startY;
- var onEnterFrame;
- var startAngle;
- var Vx;
- var Vy;
- var V;
- var _V;
- var distanceMax;
- var blockTimes = 0;
- function Control_cpu()
- {
- super();
- if(_root.gameLevel < 2)
- {
- this.hitRate = 0.25;
- }
- else if(_root.gameLevel < 5)
- {
- this.hitRate = 0.35;
- }
- else if(_root.gameLevel < 8)
- {
- this.hitRate = 0.6;
- }
- else if(_root.gameLevel < 10)
- {
- this.hitRate = 0.7;
- }
- else if(_root.gameLevel < 15)
- {
- this.hitRate = 0.8;
- }
- else
- {
- this.hitRate = 0.9;
- }
- trace("hitRate: " + this.hitRate);
- }
- function init(_role, _opp, _side, _bullet)
- {
- this.role = _role;
- this.opp = _opp;
- this.side = _side;
- this.bullet = _bullet;
- }
- function activeStart()
- {
- this.play();
- }
- function activeEnd()
- {
- this.meter_mc._x = -100;
- this.meter_mc._y = -100;
- }
- function mouseDown()
- {
- this.angle = this.getAngle();
- this.distance = this.getDistance();
- var _loc6_ = _global.lToG(this.role);
- this.meter_mc._x = _loc6_.x;
- this.meter_mc._y = _loc6_.y - 120;
- var _loc5_ = 180 + this.angle;
- var _loc4_ = 5;
- var mouseVx = _loc4_ * ExtMath.cosD(_loc5_);
- var mouseVy = _loc4_ * ExtMath.sinD(_loc5_);
- var f = int(this.distance / _loc4_) + 1;
- this.startX = this.meter_mc._x;
- this.startY = this.meter_mc._y;
- _root.roleNow.setReady();
- this.onEnterFrame = function()
- {
- this.meter_mc._x += mouseVx;
- this.meter_mc._y += mouseVy;
- this.mouseMove(this.meter_mc._x,this.meter_mc._y);
- f--;
- if(f == 0)
- {
- delete this.onEnterFrame;
- this.mouseUp();
- }
- };
- }
- function getAngle()
- {
- var _loc4_ = ExtMath.distance(this.role._x,this.role._y,this.opp._x,this.opp._y);
- var _loc3_ = Math.random();
- if(_loc3_ < 0.2)
- {
- this.startAngle = -120 + int(Math.random() * 10 - 5) * 4;
- }
- else if(_loc3_ < 0.5)
- {
- this.startAngle = -130 + int(Math.random() * 10 - 5) * 4;
- }
- else if(_loc3_ < 0.7)
- {
- this.startAngle = -160 + int(Math.random() * 8 - 4) * 3;
- }
- else
- {
- this.startAngle = -130 + int(Math.random() * 8 - 4) * 3;
- }
- if(_root.mc.iceHill instanceof MovieClip)
- {
- if(_loc3_ < this.hitRate)
- {
- this.startAngle = -120 + int(Math.random() * 10 - 5);
- trace("iceHill startAngle: " + this.startAngle);
- }
- }
- if(this.side == 1)
- {
- this.startAngle = - (this.startAngle + 180);
- }
- trace("startAngle: " + _loc3_ + " " + this.startAngle);
- return this.startAngle;
- }
- function getDistance()
- {
- var _loc3_ = ExtMath.distance(this.role._x,this.role._y,this.opp._x,this.opp._y);
- trace("dis11111: " + _loc3_);
- var _loc5_ = undefined;
- var _loc7_ = Math.random();
- trace("i::::::: " + _root.gameLevel + " " + _loc7_ + " " + this.hitRate);
- if(_loc7_ < this.hitRate)
- {
- _loc5_ = int(Math.random() * 40 - 20);
- }
- else
- {
- _loc5_ = int(Math.random() * 10 - 5) * 80 + int(Math.random() * 60 - 30);
- trace(" dis_offest: " + _loc5_);
- }
- _loc3_ += _loc5_;
- trace("dis22222: " + _loc3_);
- this.Vx = Math.sqrt(_loc3_ / 2 / _root.Vg / Math.abs(ExtMath.tanD(this.startAngle)));
- if(this.side == 2)
- {
- this.Vx = - this.Vx;
- }
- var _loc8_ = _loc3_ / this.Vx;
- this.Vy = _root.Vg * _loc8_ / 2;
- if(this.side == 1)
- {
- this.Vy = - this.Vy;
- }
- var _loc6_ = _root.playControl.wind_lv * 5;
- if(_loc6_ != 0 && !isNaN(_loc6_))
- {
- this.Vx -= _loc6_;
- }
- this.V = Math.abs(this.Vx / ExtMath.cosD(this.startAngle));
- var _loc4_ = this.V / this._V * this.distanceMax;
- trace("V: " + this.V);
- trace("distance: " + _loc4_);
- if(_loc4_ > this.distanceMax)
- {
- _loc4_ = this.distanceMax;
- }
- return _loc4_;
- }
- function checkHitIce()
- {
- }
- function mouseMove(nowX, nowY)
- {
- this.distance = ExtMath.distance(nowX,nowY,this.startX,this.startY);
- if(this.distance > this.distanceMax)
- {
- this.distance = this.distanceMax;
- }
- var _loc3_ = this.getPower(this.distance);
- _root.roleNow.setAnimation(_loc3_);
- this.meter_mc._x = nowX;
- this.meter_mc._y = nowY;
- this.meter_mc.point_mc._rotation = this.angle;
- this.meter_mc.bar.mask_mc._rotation = int(this.distance / this.distanceMax * 180);
- if(this.side == 1)
- {
- this.meter_mc.angle_txt.text = ExtMath.fixAngle(int(- this.angle)) + "┬░";
- }
- else
- {
- this.meter_mc.angle_txt.text = int(this.angle + 180) + "┬░";
- }
- this.meter_mc.power_txt.text = int(this.distance / this.distanceMax * 100) + "%";
- }
- function mouseUp()
- {
- this.startControl();
- }
- function getPower(distance)
- {
- var _loc2_ = distance / this.distanceMax;
- return _loc2_;
- }
- function startControl()
- {
- this.play();
- this.activeEnd();
- }
- }
-